<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
<head>  
<title>{{ get_app_inf key="siteName" }} - {{ $title }}</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />  
<!-- add your meta tags here -->  
  
<link href="css/my_layout.css" rel="stylesheet" type="text/css" />
<link href="css/screen/role.css" rel="stylesheet" type="text/css" />
<!--[if lte IE 7]>  
<link href="css/my_patches/patch_my_layout.css" rel="stylesheet" type="text/css" />  
<![endif]-->  
<script type="text/javascript" src="script/jquery.js"><!-- jQuery 1.2.1 --></script>
<script type="text/javascript" src="script/jquery.form.js"><!-- 表单Ajax插件 --></script>
<script type="text/javascript" src="script/yav.js"><!-- 表单验证插件 --></script>
<script type="text/javascript" src="script/jquery.yav.pack.js"><!-- 表单验证插件 --></script>
<script type="text/javascript" src="script/jquery.confirm.js"><!-- 对话框插件 --></script>

<script type="text/javascript">
// DOM载入时执行
$(function() {

	// 绑定用户列表鼠标悬停事件
	$("#rolesList tr").hover(function(){
		$(this).addClass("OMover");
	},function(){
		$(this).removeClass("OMover");
	});
	
	// 验证角色修改表单
	$("#formRoleUpdate").yav();
	$("#formRoleCreate").yav();
	
	// 添加新角色
	$("#linkRoleCreate").click(function() {
			
		// 删除已存在的修改表单
		_removeModifyForm();
		
		// 添加一个空tr，然后将表单移动到空的tr当中去
		$("#tr_0").after("<tr class='roleModifyform'><td colspan='8'>" + "</td></tr>");
		$("#formRoleCreate").appendTo(".roleModifyform td");
		
		return false;
	});
	
	
	// ajax删除一条用户记录(已经用confirm绑定)
	$(".linkRoleRemove").click(function() {

		$.get("websetup.php", {
			controller : 'admin_roles',
			action     : 'ajaxroleRemove',
			role_id  : $(this).attr("role_id")
		},function(data){
		 	if(data){
		 		location.reload();
		 	}else{
		 		alert('有其他对象已经绑定了该角色，不能直接删除！');
		 	}
		});
		
	}); //end ajax删除一条用户记录
	
	
	// 用confirm捕获删除链接的click事件
	$('.linkRoleRemove').confirm({
		msg:'<img src="images/notice.gif" /> ',
		stopAfter:'ok',
		eventType:'click',
		timeout:3000,
		buttons: {
			ok:'确认',
			cancel:'取消',
			separator:' | '
		}
	});

});

// 修改用户表单显示及预填写
function roleUpdate( role_id, rolename, description ) {

	// 删除已存在的修改表单
	_removeModifyForm();
	
	// 点击修改链接时在当前tr后面插入修改表单
	$("#tr_" + role_id).after( "<tr class='roleModifyform'><td colspan='8'>" + "</td></tr>" );
	$("#formRoleUpdate").appendTo(".roleModifyform td");
	
	// 预填写表单
	$("#u_role_id").val(role_id);
	$("#u_rolename").val(rolename);
	$("#u_description").val(description);

}

// 删除已存在的修改表单
function _removeModifyForm() {
	$("#formRoleCreate").appendTo("#divRoleCRUD");
	$("#formRoleUpdate").appendTo("#divRoleCRUD");
	$("#rolesList .roleModifyform").remove();
}

</script>

</head>  
<body> 
  <div id="page_margins">

    <div id="border-top">
      <div id="edge-tl"></div>
      <div id="edge-tr"></div>
    </div>
    <div id="page">
      {{ include file="admin/Websetup_header.html" }}
      {{ include file="admin/Websetup_nav.html" }}

      <div id="main">
        <div id="col1">
          <div id="col1_content" class="clearfix">
				{{ webcontrol type="menu" name="myMenu" }}
          </div>
        </div>
        <div id="col3">
          <div id="col3_content" class="clearfix">
            
				{{ include file = "admin/Websetup_roles_list.html" }}
            
          </div>
          <!-- IE Column Clearing -->
          <div id="ie_clearing"> &#160; </div>
        </div>
      </div>
      <!-- begin: #footer -->
      {{ include file="admin/Websetup_footer.html" }}
    </div>
    <div id="border-bottom">
      <div id="edge-bl"></div>
      <div id="edge-br"></div>
    </div>
  </div>
</body>
</html>
